home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr27 / dumps100.zip / DUMPS.PAS < prev    next >
Pascal/Delphi Source File  |  1995-02-24  |  2KB  |  78 lines

  1. {$I-}{$S-} (* Check IO with IOResult; disable stack checking *)
  2. Program DumpScreen; (* Even works on screens larger than 80x25! *)
  3. procedure showhelp(const problem :byte);
  4. (* If any *foreseen* errors arise, we are sent here to
  5.    give a little help and exit (relatively) peacefully *)
  6. const
  7.   progdesc = 'DumpScreen - Free DOS utility: '+
  8.              'Dump contents of entire screen to a text file.';
  9.   author   = 'v1.00: February 24, 1995. '+
  10.              '(c) 1995 by David Daniel Anderson - Reign Ware.';
  11.   usage    = 'Usage: DumpS <textfile>';
  12. var
  13.   message : string[50];
  14. begin
  15.   writeln(progdesc);
  16.   writeln(author);    writeln;
  17.   writeln(usage);     writeln;
  18.   if problem > 0 then begin
  19.     case problem of
  20.       1 : message:='Unexpected error opening or closing output file.';
  21.     else  message:='Unanticipated error of unknown type.';
  22.     end;
  23.     writeln (#7,message);
  24.   end;
  25.   halt(problem)
  26. end;
  27.  
  28. Procedure GotoXY(X,Y : Byte); Assembler;
  29. (* From SWAG, unattributed *)
  30. Asm
  31.   MOV DH, Y    { DH = Row (Y) }
  32.   MOV DL, X    { DL = Column (X) }
  33.   DEC DH       { Adjust For Zero-based Bios routines }
  34.   DEC DL       { Turbo Crt.GotoXY is 1-based }
  35.   MOV BH,0     { Display page 0 }
  36.   MOV AH,2     { Call For SET CURSOR POSITION }
  37.   INT 10h
  38. end;
  39.  
  40. Function ScrnChar: Char;
  41. (* From SWAG, unattributed *)
  42. begin
  43.   Asm
  44.     push  bx
  45.     mov   ah,8
  46.     xor   bx,bx
  47.     int   16
  48.     mov   @Result,al
  49.     pop   bx
  50.   end;
  51. end;
  52.  
  53. var
  54.   scrncols: byte absolute $0040:$004a; {from Lou Duchez, found in SWAG}
  55.   scrnrows: byte absolute $0040:$0084; {from Lou Duchez, found in SWAG}
  56.   MaxX, MaxY : byte;
  57.   x,y: byte;
  58.   dumpfile: text;
  59.  
  60. BEGIN
  61.   if ParamCount <> 1 then showhelp(0);
  62.   assign(dumpfile, ParamStr(1));
  63.   rewrite(dumpfile); if ioresult <> 0 then showhelp(1);
  64.  
  65.   MaxX := scrncols;
  66.   MaxY := scrnrows + 1;
  67.   For y := 1 to MaxY do begin
  68.     For x := 1 to MaxX do begin
  69.       GotoXY(x,y);
  70.       Write(dumpfile, ScrnChar);
  71.     end;
  72.     Writeln(dumpfile);
  73.   end;
  74.   close(dumpfile); if ioresult <> 0 then showhelp(1);
  75.   GotoXY(1,MaxY);
  76.   Writeln('Screen contents successfully saved in "',ParamStr(1),'".');
  77. end.
  78.